$(document).ready(function(){
	sessionUrl();
	showsession();
	
	showOrHideFootBar();
	checkmsg();
	checklinks();
	$('.clrBtn').click(function(){
		$('.s-input').val('');
		$(this).addClass('hide');
		$('.s-input').focus();
	});
});

function searchIt(){
	var content = $('.s-input').val();
	$('.clrBtn').removeClass('hide');
	//POST到PHP处理
	$.ajax({
		type:'post',
		url:'../actions/searchAction.php',
		data:	{
					act			:'search',
					content		:content
				}, 
		async: true,	
		beforeSend:function(){
			$('.waiting').removeClass('hide');
			$('.mist').removeClass('hide');		
		},
		success:function(data){
 			if(data){		
				$('.searchResultDiv').html(data);
				show_1stpic_or_maxheight();
			}else{
				var noresult = "<div class='noresult'>抱歉，没有相关内容...</div>";
				$('.searchResultDiv').html(noresult);
			}
			$('.waiting').addClass('hide');
			$('.mist').addClass('hide');
		}
	});
}


//判断内容是否有图片，
//如果有图片：仅展示第一张图，文字不做展示；
//如果没有图片：展示文字，max-height为60px;
function show_1stpic_or_maxheight(){
	$('.postcontent').each(function(){
		console.log('23232323232323232323');
		var imgs = $(this).find('img');
		imglength = imgs.length;
		if(imglength > 0){
			var showimg = document.getElementById(imgs[0].id);
			$(this).html(showimg);
		}else{
			$(this).css('max-height','60px');
		}
	});
}

